<?php
include("../../controllers/read.php");
$db = openDB("../../database.sqlite");
$config = getConfig($db);
$revisions = sqlite_fetch_all(sqlite_query($db,"SELECT * FROM revisions ORDER BY time DESC"));
include("../../lib/utilities.php");
echo "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n";
?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
  	<title><?php echo $config['name'] ?></title>
  	<link><?php echo $config['url'] ?></link>
  	<language>en-us</language>
  	<description><?php echo $config['tagline'] ?></description>
  	<?php
  	foreach($revisions as $revision) {
  	  $page = getPage($db,$revision['pageid']);
  	  ?>
      <item>
      	<title><?php echo $page['title'] ?></title>
      	<description><![CDATA[<p><em>Revised by <a href='<?php echo $config['url'] ?>?show=<?php echo $revision['author'] ?> (author)'><?php echo $revision['author'] ?></a> 
            (<a href='http://ws.arin.net/cgi-bin/whois.pl?queryinput=<?php echo $revision['ip'] ?>'><?php echo $revision['ip'] ?></a>). 
            now it's:</em></p>
        <?php echo textilize($revision['body']) ?>]]></description>
      	<pubDate><?php echo date("r",$revision['time']) ?></pubDate>
      	<dc:creator><?php echo $revision['author'] ?></dc:creator>
      	<link><?php echo $config['url'] ?>?show=<?php echo $page['title'] ?></link>
      	<?php
      	$tags = split(" ",$page['tags']);
      	for($j=0; $j<count($tags); $j++) {
      	  $tag = $tags[$j];
      	  echo "<category>$tag</category>\n";
      	}
      	?>
      </item>
  	<?php }?>
	</channel>
</rss>